<?php

/**
 * Beca form base class.
 *
 * @method Beca getObject() Returns the current form's model object
 *
 * @package    BecArTe
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseBecaForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                       => new sfWidgetFormInputHidden(),
      'nombre'                   => new sfWidgetFormInputText(),
      'descripcion'              => new sfWidgetFormTextarea(),
      'cupo'                     => new sfWidgetFormInputText(),
      'monto'                    => new sfWidgetFormInputText(),
      'dias_limite_requisitos'   => new sfWidgetFormInputText(),
      'fecha_limite_inscripcion' => new sfWidgetFormDate(),
      'fecha_inicio'             => new sfWidgetFormDate(),
      'fecha_fin'                => new sfWidgetFormDate(),
      'categoria_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('categoria'), 'add_empty' => false)),
      'generoInforme'            => new sfWidgetFormInputCheckbox(),
      'created_at'               => new sfWidgetFormDateTime(),
      'updated_at'               => new sfWidgetFormDateTime(),
      'created_by'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Creator'), 'add_empty' => true)),
      'updated_by'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Updator'), 'add_empty' => true)),
      'version'                  => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'                       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'nombre'                   => new sfValidatorString(array('max_length' => 50)),
      'descripcion'              => new sfValidatorString(array('max_length' => 1000)),
      'cupo'                     => new sfValidatorInteger(array('required' => false)),
      'monto'                    => new sfValidatorPass(array('required' => false)),
      'dias_limite_requisitos'   => new sfValidatorInteger(array('required' => false)),
      'fecha_limite_inscripcion' => new sfValidatorDate(),
      'fecha_inicio'             => new sfValidatorDate(),
      'fecha_fin'                => new sfValidatorDate(),
      'categoria_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('categoria'))),
      'generoInforme'            => new sfValidatorBoolean(array('required' => false)),
      'created_at'               => new sfValidatorDateTime(),
      'updated_at'               => new sfValidatorDateTime(),
      'created_by'               => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Creator'), 'required' => false)),
      'updated_by'               => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Updator'), 'required' => false)),
      'version'                  => new sfValidatorInteger(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Beca', 'column' => array('nombre')))
    );

    $this->widgetSchema->setNameFormat('beca[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Beca';
  }

}
